﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
struct FoodInfo
{
    public bool HasMeat { get; set; }
    public double Calories { get; set; }
    public double ComplexCarbs { get; set; }
    public double Cost { get; set; }
    public double GramsPerUnit { get; set; }
    public double ProteinIndex { get; set; }
    public double Proteins { get; set; }
    public double Salt { get; set; }
    public double SaturatedFats { get; set; }
    public double SimpleCarbs { get; set; }
    public double UnsaturatedFats { get; set; }
    public ServingUnit ServingUnit { get; set; }
    public string Name { get; set; }

    // todo: make sure everything is read properly here and in the other files
    public FoodInfo(Dictionary<string, string> dict)
        : this() {
        this.Name = dict["name"].Split(',')[0];
        this.ServingUnit = (ServingUnit)Enum.Parse(typeof(ServingUnit), dict["unit"], true);
        this.GramsPerUnit = double.Parse(dict["gramsperunit"]);
        this.Calories = double.Parse(dict["calories"]);
        this.Proteins = double.Parse(dict["proteins"]);
        this.ProteinIndex = double.Parse(dict["proteinindex"]);
        this.SimpleCarbs = double.Parse(dict["simplecarbs"]);
        this.ComplexCarbs = double.Parse(dict["complexcarbs"]);
        this.SaturatedFats = double.Parse(dict["saturatedfats"]);
        this.UnsaturatedFats = double.Parse(dict["unsaturatedfats"]);
        this.Salt = double.Parse(dict["natrium"]);
        this.Cost = double.Parse(dict["cost"]);
        this.HasMeat = Helpers.ToBool(dict["hasmeat"]);
    }

    public FoodInfo(string path)
        : this(Helpers.ReadFile(path)) {



    }
}